<div class="download">
    <div class="left">
        <img src="{{$style_host}}atw/images/applogo.png">
        <div>
            <div class="h1 fw700">ASIA TECH WIRE</div>
            <P>Grasp technology trends</P>
        </div>
    </div>
    <div class="right fw700">
        <a href="#">Download</a>
    </div>
</div>




<!-- googlead1 -->
{{--<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3493373814157275"
        crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-3493373814157275"
     data-ad-slot="2268001927"></ins>
<script>
    (adsbygoogle = window.adsbygoogle || []).push({});
</script>--}}


<script type="text/javascript">
    // 手机端展开
    $(function ($) {
        $('#menu').leftMenu({
            "triggerBtn": ".btn"
        }).init()
    })

    // 加载更多
    $("#news_cate_more").on('click', function () {
        let nextUrl = $("#nextPage_url").text()
        let min_id = $("#nextPage_min_id").text()
        toCateMore(nextUrl, min_id)
    })

    // 加载下一页：栏目的下一页
    function toCateMore(url, min_id = 0) {
        console.log('加载更多', url, min_id);
        $.ajax({
            type: 'post',
            url: url,
            // data: 'name=zhangsan&age=20'
            data: JSON.stringify({min_id: min_id}),
            contentType: 'application/json',
            dataType: "json",
            // contentType: 'application/x-www-form-urlencoded',
            // 这个方法在请求发送前调用，可以用来做表单校验、用来做请求等待动画的调用
            /*beforeSend: function () {
                // 返回false是取消发送
                return false
            },*/
            // 会自动帮我们把返回的数据根据响应头设置的类型进行转换好（也就是会自动转成json对象）
            success: function (res) {
                console.log('执行结果', res)
                if (res.code == 400) {
                    alert(res.msg)
                } else {
                    $("#news_list").append(res.data.html)
                    $("#nextPage_url").text(res.data.nextUrl)
                    $("#nextPage_min_id").text(res.data.min_id)
                    if (!res.data.html) {
                        $("#news_cate_more").css('display', 'none');
                    }
                }
            },
            // xhr是ajax对象
            error: function (xhr) {
            }
        });
    }

    // 将时间戳转换为日期格式并展示
    $(".show_date").text(getDateTime($(".show_date").data('stamp') * 1000, 'yy.mm.dd'))
    $(".show_time").text(getDateTime($(".show_time").data('stamp') * 1000, 'datetime'))
    $(".line .blue").each(function (index, element) {
        let stamp = $(this).data('stamp');
        $(this).text(getDateTime(stamp * 1000, 'hh:mm'))
        //$(this).text(getDateTime(stamp, 'time'))
    });

    // 将时间戳转换为日期格式
    function getDateTime(stamp, format = 'time') {
        var date = new Date(stamp)
        var YY = date.getFullYear();
        var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
        var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
        var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
        var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
        var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
        if (format == 'time') {
            return hh + ':' + mm + ':' + ss;
        } else if (format == 'datetime') {
            return YY + '-' + MM + '-' + DD + ' ' + hh + ':' + mm + ':' + ss;
        } else if (format == 'date') {
            return YY + '-' + MM + '-' + DD;
        } else if (format == 'yy.mm.dd') {
            return YY + '.' + MM + '.' + DD;
        } else if (format == 'hh:mm') {
            return hh + ':' + mm;
        }
    }

</script>
